# -*- coding: utf-8 -*-
# @Time : 2025/3/15 16:24
# @Author : Qingjun.Luo
# @Email : lqj831010@163.com
# @File : 边界的填充.py
# @Project : open-cv


import cv2
import argparse
import numpy as np
import matplotlib.pyplot as plt

def cv_show(name, img):
    cv2.imshow(name, img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


# img/mycat.png
img = cv2.imread("../img/car.png") # 读取图片

# cv_show('image', img)

catImg = cv2.imread("../img/cat.jpg") # 读取图片
cat = catImg[0:200, 0:220]
# cv_show('catShow', cat)

b, g, r = cv2.split(catImg)
# print(b)


#  边界填充
top_size, bottom_size, left_size, right_size =(50,50,50,50)

relicate = cv2.copyMakeBorder(catImg, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_REPLICATE)
reflect = cv2.copyMakeBorder(catImg, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_REFLECT)
reflect101 = cv2.copyMakeBorder(catImg, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_REFLECT_101)
wrap = cv2.copyMakeBorder(catImg, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_WRAP)
constant = cv2.copyMakeBorder(catImg, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_CONSTANT,value=10)

plt.subplot(231), plt.imshow(catImg, 'gray'), plt.title('ORIGINAL')
plt.subplot(232), plt.imshow(relicate, 'gray'), plt.title('RELICATE')
plt.subplot(233), plt.imshow(reflect, 'gray'), plt.title('REFLECT')
plt.subplot(234), plt.imshow(reflect101, 'gray'), plt.title('REFLECT101')
plt.subplot(235), plt.imshow(wrap, 'gray'), plt.title('WRAP')
plt.subplot(236), plt.imshow(constant, 'gray'), plt.title('CONSTANT')
# plt.show()

# 图形重叠的应用
img_car2 = cv2.imread("../img/car.png")
img_dog2 = cv2.imread("../img/dog.jpg")
print("img_dog2形状: "+ str(img_dog2.shape) )
print("img_car2形状: "+ str(img_car2.shape) )

img_dog3 = cv2.resize(img_dog2,(550,949))
print("img_dog3形状: "+ str(img_dog3.shape) )

# img_car2+img_dog3
